package cn.edu.just.firstjavaapp.l8;

public class RectangleV2 implements Comparable<RectangleV2>{
    int width;
    int height;

    public RectangleV2(int width, int height) {
        this.width = width;
        this.height = height;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getArea(){
        return width*height;
    }

    public int getZhouChang(){
        return 2*(width+height);
    }

    @Override
    public int compareTo(RectangleV2 o) {  //自然序
        return this.getArea() - o.getArea();
    }

    public void print(){
        System.out.println("Rectangle{width="
                +width+",height="+height
                +",area:"+getArea()+",周长:"+getZhouChang()+"}");
    }
}
